<!DOCTYPE html>
<script src="/js-test-resources/testharness.js"></script>
<script src="/js-test-resources/testharnessreport.js"></script>
<script src="resources/get-request-header.js"></script>
<script>
var t = async_test('Cookies set by document.cookie are sent in a WebSocket handshake');
t.step(function() {
    var cookie_id = 'test_' + Date.now() + '.' + Math.random();

    document.cookie = cookie_id + '=1; Path=/echo-request-headers';

    connectAndGetRequestHeader('cookie').then(t.step_func(function(actual) {
        var expected = cookie_id + '=1';
        assert_equals(actual, expected);

        document.cookie = cookie_id + '=1; Path=/echo-request-headers; Max-Age=0';

        t.done();
    }), t.unreached_func("cookie header lookup failed"));
});
</script>
